
import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate';

export default createStore({
  state: {
    user:{name:null,uid:0,values:0},  //用户对象全局
    txt:'',                           //路径
    userinitUid:0,                    //上架商品的uid
    upGoodsID:0,                      //商品编号
  },
  getters: {

  },
  mutations: {
    //更新用户对象
    userinit(state,users) {
      state.user={
        name:users.name,
        uid:users.uid,
        values:users.values
      }
    },
    //更新路径
    setTxt(state,txt) {
      state.txt=txt
    },
    //更新商户
    updateUserInitUid(state, uid) {
      state.userinitUid = uid;
    },
    //更新商品编号
    updateUpGoodsID(state,id){
      state.upGoodsID=id
    },
    //更新余额
    updatevalues(state,values){
      state.user.values=values
    }
  },
  actions: {

  },
  modules: {

  },
  plugins: [
    createPersistedState({
      paths: ['user' , 'txt', 'userinitUid' , 'upGoodsID'], 
    })
  ]
})

